//
//  FZFZDBTools.h
//
//  Created by 李忠 on 7/2/16.
//  Copyright © 2016 FZLZ. All rights reserved.
//

#import <FMDB/FMDB.h>

typedef void(^SuccessBlcok)(NSArray<NSDictionary *> *array);
typedef void(^ErrorBlcok)(NSError *error);

typedef NS_ENUM(NSInteger, FZQuerySortType){
    FZQuerySortAsc = 0, //升序
    FZQuerySortDesc = 1 //降序
};

@interface FZDBTools : FMDatabase

//创建一个数据库
+ (instancetype)shareManagerWithFilePath:(NSString *)filePath;


//创建一个表
- (BOOL)createTableSQL:(NSString *)sql;

//根据提供的字典向表中插入数据
- (BOOL)insertWithTableName:(NSString *)tableName withNewValues:(NSDictionary *)newValues;

//删除指定key 值得数据
- (BOOL)delWithTableName:(NSString *)tableName withKey:(NSDictionary *)key;

//更新指定Key中的行
- (BOOL)upadateWithTableName:(NSString *)tableName newValue:(NSDictionary *)newValues require:(NSDictionary *)require;

//查询数据中所有的数据
- (void)queryAllWithTableName:(NSString *)tableName withSuccessBlock:(SuccessBlcok)scuccessBlock withErrorBlock:(ErrorBlcok)errorBlock;
//查询数据中所有的数据
- (void)queryAllWithTableName:(NSString *)tableName withSort:(FZQuerySortType)sort forKey:(NSString *)key withSuccessBlock:(SuccessBlcok)scuccessBlock withErrorBlock:(ErrorBlcok)errorBlock;

//模糊查询
- (NSArray<NSDictionary *> *)queryAllProductWithWorld:(NSString *)search;

@end
